package com.robinmouren.entity;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


@Data
@Builder
public class OrderStatus implements Serializable {

    private Integer status;

    private String tip;

    private LocalDateTime time;

    public static OrderStatus set(int status, String tip, LocalDateTime time) {
        return OrderStatus.builder()
                .status(status)
                .tip(tip)
                .time(time)
                .build();
    }


    // 询价单状态进度
    public static List<OrderStatus> listQuotation() {
        List<OrderStatus> list = new ArrayList<>();
        list.add(OrderStatus.set(1, "创建询价单", LocalDateTime.now()));
        list.add(OrderStatus.set(2, "询价单审核", null));
        list.add(OrderStatus.set(3, "询价单询价", null));
        list.add(OrderStatus.set(6, "询价单报价", null));
        return list;
    }


    public static List<OrderStatus> listOrder() {
        List<OrderStatus> list = new ArrayList<>();
        // TODO 补全状态信息
        list.add(OrderStatus.set(7, "创建订单", LocalDateTime.now()));
        list.add(OrderStatus.set(8, "拆分路线", null));
        list.add(OrderStatus.set(9, "拆分货物", null));
        list.add(OrderStatus.set(10, "签订合同", null));
        list.add(OrderStatus.set(11, "运输调度", null));
        list.add(OrderStatus.set(12, "创建订单", null));

        return list;
    }


    // 修改列表中某一项信息
    public static void reviseList(List<OrderStatus> list, Integer status, LocalDateTime time) {


        list.forEach(item -> {
            if (item.getStatus().equals(status)) {
                item.setTime(time);
            }
        });
    }


}
